# -*- coding: utf-8 -*-
"""
Created on Thu Dec 10 14:39:50 2015

@author: liliangrong
"""

import cookielib

import urllib2



#创建MozillaCookieJar实例对象

cookie = cookielib.MozillaCookieJar()

#从文件中读取cookie内容到变量

cookie.load('cookie.txt', ignore_discard=True, ignore_expires=True)

#创建请求的request

req = urllib2.Request("http://www.taobao.com")

#利用urllib2的build_opener方法创建一个opener

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))

response = opener.open(req)

page_source = response.read()
with open('taobao.html','w+') as f:
    f.write(page_source)
f.closed